﻿using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;

namespace WebApplication4.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class TestController : ControllerBase
    {


        private TestOption _option;

        private IConfiguration _configuration;
       
        public TestController(IOptions<TestOption> options,IConfiguration _configuration)
        {
            this._option = options.Value;
            this._configuration = _configuration;
        }
        // GET
        [HttpGet]  
        [Route("test2")]
        public Task  Get2()
        {
            
            Console.WriteLine(_configuration);
            Console.WriteLine(_option.Settings.Count);
            return Task.CompletedTask;
        }
        [Authorize(Roles ="admin")]
        [HttpGet]  
        [Route("test")]
        public string Get()
        {
            
            
            Console.WriteLine("test");
            foreach (var c in this.HttpContext.User.Claims)
            {
                Console.WriteLine($"c:{c.Type} {c.Value} {c.Issuer}");
            }

            return "test";
        }
    }
}